var adr = "http://localhost:8080";

//解析服务器返回的数据
function parseData(data){
    if(data.status == 200){
        return data.data;
    } else if(data.status == 201){
        alert("请进行登录!");
        window.location.href = "./index.html";
    } else {
        alert(data.msg);
    }
}

//校验cookie是否存在，不存在则跳转到首页
function checkToken() {
    var vtoken = getCookie("P-TOKEN");
    if(vtoken == null || vtoken == "" || vtoken == undefined){
        window.location.href = "./index.html";
    }
}

function getCookie(cookieName) {
    var strCookie = document.cookie;
    var arrCookie = strCookie.split("; ");
    for(var i = 0; i < arrCookie.length; i++){
        var arr = arrCookie[i].split("=");
        if(cookieName == arr[0]){
            return arr[1];
        }
    }
    return "";
}